<p class='contentmenu'>
    <?php if(isset($prev)) { ?>[ <?php echo $html->link($prev['Meeting']['meeting_num'],array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetings','action'=>'view','id'=>$prev['Meeting']['id'])); ?> ]<?php } ?>
    <?php if(($secretariat[$meeting['Meeting']['id']])||(isset($permission['Attendance']['View']) && $permission['Attendance']['View'])) { ?> [ <?php echo $html->link(__('Attendance',true),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetings','action'=>'attendance','id'=>$meeting['Meeting']['id'])); ?> ] <?php } ?>
    <?php if(($secretariat[$meeting['Meeting']['id']]) && (empty($invited))) { ?> [ <?php echo $html->link(__('Invitation to meeting',true),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetings','action'=>'invite','id'=>$meeting['Meeting']['id'])); ?> ] <?php } ?>
    <?php if(($secretariat[$meeting['Meeting']['id']])||(isset($permission['Meetingtodo']['View']) && $permission['Meetingtodo']['View'])) { ?> [ <?php echo $html->link(__('Todo',true),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetingtodos','action'=>'index','id'=>$meeting['Meeting']['id'])); ?> ] <?php } ?>
    <?php if(isset($next)) { ?> [ <?php echo $html->link($next['Meeting']['meeting_num'],array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetings','action'=>'view','id'=>$next['Meeting']['id'])); ?> ]<?php } ?>
    
    <?php 
        if((isset($permission['Decision']['Create']) && $permission['Decision']['Create'])||($secretariat[$meeting['Meeting']['id']])) {
            echo '<br/>'.__('Decision',true).': ';
            echo '[ ';
            echo $html->link(__("Add 1 decision",true),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'decisions','action'=>'add','meetingid'=>$meeting['Meeting']['id'])); 
            echo ' ] ';
            if (isset($addminute)) { 
                $text = __("Edit minutes",true); 
            } else { 
                $text = __("Add minutes",true); 
            }
            echo '[ ';
            echo $html->link($text, array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'decisions','action'=>'minutes','id'=>$meeting['Meeting']['id']));
            echo ' ] ';
/*
            if(strlen($meeting['Meeting']['minutes_raw'])==0) {
                echo $html->link(__("Add legacy minutes",true),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'decisions','action'=>'addminutes','meetingid'=>$meeting['Meeting']['id']));
            } else {
                echo $html->link(__("Edit legacy minutes",true),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetings','action'=>'editminutes','meetingid'=>$meeting['Meeting']['id']));
            }
            echo ' ]';
*/
        }
        if(!empty($N) && ((($secretariat[$meeting['Meeting']['id']])) && (empty($needcheck) ))){ 
            echo '['.$ajax->link(__('Add all decision to minutes',true), array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetings','action'=>'approvedecision','meetingid'=>$meeting['Meeting']['id']),array('complete'=>'location.reload()','escape'=>false),sprintf(__('This will put all of the decisions in the minutes for the chairperson to approve. Proceed?', true))).']';
        }
        if(isset($secretariat[$meeting['Meeting']['id']]) && $secretariat[$meeting['Meeting']['id']]) {
            echo ' [ ';
            echo $html->link(__("Ask for status updates",true),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetings','action'=>'announcedecisions','meetingid'=>$meeting['Meeting']['id']),null,__('Are you sure you want to announce all of the decisions?', true));
            echo ' ]';
        }
    
        echo '<br/>'.__('Minutes',true).': ';
        
        if ($minutes_approved){
            echo __('Approved',true).' ';
            if($minute_comment){
                echo '-'.__('With Comment',true).' ';
            }
        }
        elseif ($N==0 && count($decisions)) {
            echo __('Awaiting approval',true).' ';
        } else {
            __('In draft mode');
        }
        
        //if all status are accepted
        if ($N==0 && count($decisions)) { 
            if ($secretariat[$meeting['Meeting']['id']]) {
                // secretariat
                if($minutes_approved) {
                    echo "[ ";
                    echo $html->link( __("Distribute minutes",true),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetings','action'=>'announceminute','id'=>$meeting['Meeting']['id']),null,null,false);
                    echo $announced ? ' - '.__('done!',true) : '';
                    echo " ] ";
                }elseif(!$minute_comment){
                    echo "[ ";
                    echo $html->link( __("Send for approval",true),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetings','action'=>'approval','id'=>$meeting['Meeting']['id']),null,null,false);
                    echo $approval_sent ? ' - '.__('done!',true) : '';
                    echo " ] ";
                }elseif ($minute_comment){
                    echo "[ ";
                    echo $html->link( __("Send for approval",true)."(".__("after change",true).")",'/'.$dcommittee['Committee']['short_name'].'/meetings/approval/'.$meeting['Meeting']['id'].'/1',null,null,false);
                    echo $reapproval_sent ? ' - '.__('done!',true) : '';
                    echo " ] ";
                }
            } else if ($auth_user['User']['id'] == $chairperson['User']['id'] || $permission['Minute approval']['Create']){
                // for chairperson
                if (!$minutes_approved) {
                    if ($auth_user['User']['id'] == $chairperson['User']['id'] || $permission['Minute approval']['Create']){
                        echo '[ ';
                        echo $html->link(__('Approve minutes',true),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'decisions','action'=>'printminutes','id'=>$meeting['Meeting']['id']),array('target'=>'_blank'),null,false);
                        echo ' ] ';
                    }
                } 
            } 
        }
            
        //"view minutes" appear only if the minute's availability was announced
        if ($minutes_approved && $N==0){
            //if(strlen($meeting['Meeting']['minutes_raw'])>0){echo ' [ '.$html->link(__('View Legacy Minutes', true), array('committee'=>$dcommittee['Committee']['short_name'],'action'=>'minutes',$meeting['Meeting']['id']), array('target'=>'_blank')).'] ';}
            echo ' [ '.$html->link(__("View Minutes",true),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'decisions','action'=>'printminutes','id'=>$meeting['Meeting']['id']),array('target'=>'_blank')).' ]';
        } 
        echo ' [ '.$html->link(__("View Report",true),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'reports','action'=>'meeting','id'=>$meeting['Meeting']['id']),array('target'=>'_blank')).' ] ';
        
    ?>
</p>
<div class="meetings view">
<h2>
<?php 
echo $meeting['Meeting']['meeting_title'].' '.$meeting['Meeting']['meeting_num'];
echo "&nbsp;";
if ($minutes_approved){
    echo "(".__('Minutes approved',true).")";
}?>
</h2>

<table cellspacing='0' cellpadding='0' border='0' id="noborder">
<tr>
    <td class="leftcolumn">
        <div class="contentsummary">
        <ul>
            <li><span class="viewtitle"><?php __('Committee'); ?>: </span><?php echo $meeting['Committee']['name']; ?></li>
            <li><span class="viewtitle"><?php __('Meeting Title'); ?>: </span><?php echo $meeting['Meeting']['meeting_title'];?></li>
            <li><span class="viewtitle"><?php __('Meeting No'); ?>: </span><?php echo $meeting['Meeting']['meeting_num'];?></li>
            <li><span class="viewtitle"><?php __('Meeting Date'); ?>: </span><?php echo date(Configure::read('date_format'),strtotime($meeting['Meeting']['meeting_date'])); ?>
            &nbsp;<?php echo date(Configure::read('time_format'),strtotime($meeting['Meeting']['meeting_date'])); ?></li>
            <li><span class="viewtitle"><?php __('Venue'); ?>: </span><?php echo $meeting['Meeting']['venue']; ?></li>
            <li><span class="viewtitle"><?php __('Chairperson'); ?>: </span><?php echo $chairperson['Title']['short_name'].' '.$chairperson['User']['name']; ?></li>
        </ul>
        </div>

        <?php 
            If(date("Y/m/d",mktime())<date("Y/m/d",strtotime($meeting['Meeting']['meeting_date']))){
                echo '<fieldset class="agenda">';
                    echo "<legend>";
                        __('Agenda');
                    echo  "</legend>";
                    if (!empty($meeting['Meeting']['agenda'])){
                        echo nl2br($meeting['Meeting']['agenda']);
                    }else{
                        echo __('No agenda has been set for this meeting yet');
                    }
                echo "</fieldset>";
                
            }
            If(($secretariat[$meeting['Meeting']['id']]) ||(isset($permission['Decision -Upcoming meeting']['View']) && $permission['Decision -Upcoming meeting']['View'])||(isset($permission['Decision']['Create']) && $permission['Decision']['Create'])|| (date("Y/m/d",mktime()) >= date("Y/m/d",strtotime($meeting['Meeting']['meeting_date'])))){
                echo $this->element('decision_list',array('model'=>'meeting'));
                if(!empty($N) && ((($secretariat[$meeting['Meeting']['id']])) && (empty($needcheck) ))){ 
					echo '<div style="float:right">['.$ajax->link(__('Add all decision to minutes',true), array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'meetings','action'=>'approvedecision','meetingid'=>$meeting['Meeting']['id']),array('complete'=>'location.reload()','escape'=>false),sprintf(__('This will put all of the decisions in the minutes for the chairperson to approve. Proceed?', true))).']</div>';
                }
            }
        ?>
    </td>
    <td class="rightcolumn">
    
        <?php if(isset($meeting['MultiFile'])) { ?>
        <fieldset id="dfiles">
        <legend><?php __('Files for this meeting');?></legend>
        <div class="fieldset-inside">
        <?php 
            if(isset($meeting['MultiFile']['agenda'])){
                echo $this->element('multifile',array('multifiles'=>$meeting['MultiFile']['agenda'],'title'=>__('Agenda',true)));
            }
            if(isset($meeting['MultiFile']['minutes'])){
                echo $this->element('multifile',array('multifiles'=>$meeting['MultiFile']['minutes'],'title'=>__('Minutes',true)));
            }
            if(isset($meeting['MultiFile']['presentations'])){
                echo $this->element('multifile',array('multifiles'=>$meeting['MultiFile']['presentations'],'title'=>__('Presentations',true)));
            }
        ?>
        </div>
        </fieldset>
        <?php } ?>

        <fieldset>
        <legend><?php __('Comments for this meeting');?>
        <?php echo $comment->no_of_comments('Meeting',$meeting)? ': '.$comment->no_of_comments('Meeting',$meeting) : '' ?>    
        </legend>
        <div class="fieldset-inside">
        <?php echo $comment->disp_comment('Meeting',$meeting) ?>
        </div>
        </fieldset>
        
    </td>
</tr>
</table>



</div>

